package com.itheima.edu.info.manager.service;

import com.itheima.edu.info.manager.dao.StudentDao;
import com.itheima.edu.info.manager.dao.TeacherDao;
import com.itheima.edu.info.manager.domain.Student;
import com.itheima.edu.info.manager.domain.Teacher;

public class TeacherService {




    public static boolean isExits(String sid) {
        boolean flag=false;
        Teacher[] tea=TeacherDao.findAllTeacher();
        for (int i = 0; i < tea.length; i++) {
            Teacher teacher = tea[i];
            if(tea[i]!=null&&teacher.getId().equals(sid)){
                flag=true;
                break;
            }
        }
        return flag;
    }

    public static boolean addteacher(Teacher tea) {
        return TeacherDao.addTeacher(tea);
    }

    public static Teacher[] quarryTeacher() {
        Teacher[] tea=TeacherDao.quarryteacher();
        boolean flag=false;
        for (int i = 0; i < tea.length; i++) {
            if(tea[i]!=null){
                flag=true;
            }
        }
        if(flag){
            return tea;
        }else{
            return null;
        }
    }

    public static void deleteTeahcer(String sid) {
        TeacherDao.deleteTeacher(sid);
    }

    public static void updataTeacher(Teacher tea, String sid) {
        TeacherDao.updataTeacher(tea,sid);
    }
}
